<script setup lang="ts">
import { biProductLineData } from "@/views/mes/lineBi/common/commonTs";

const props = defineProps({
  formData: {
    type: Object,
    default: () => ({
      productCode: "",
      deviceName: "",
      deviceCode: "",
    }),
  },
});

//选择成品弹窗
const productDialogSelect = ref({
  visible: false,
});
const changeProductVisible = (val: boolean, data: any) => {
  productDialogSelect.value.visible = val;
  if (data) {
    props.formData.productId = data.id;
    props.formData.productName = data.materialName;
    props.formData.productCode = data.materialCode;
  }
};
// 回显的数据
const productBackList = ref([]);
const showWorkOrderSelect = () => {
  productDialogSelect.value.visible = true;
};
</script>

<template>
  <el-input
    v-model="props.formData.productCode"
    placeholder="请选择成品物料"
    clearable
    readonly
    style="width: 100%"
    @click="showWorkOrderSelect"
  >
    <template #append>
      <el-button type="success" plain @click="showWorkOrderSelect"
      >选择</el-button
      >
    </template>
  </el-input>

  <product-select
    :visible="productDialogSelect.visible"
    @change-visible="changeProductVisible"
    :materialType="3"
    :backList="productBackList"
  />
</template>

<style scoped lang="scss"></style>
